1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgRenderer; 26 27 private import glib.Str; 28 private import gobject.ObjectG; 29 private import pango.PgColor; 30 private import pango.PgFont; 31 private import pango.PgGlyphItem; 32 private import pango.PgGlyphString; 33 private import pango.PgLayout; 34 private import pango.PgLayoutLine; 35 private import pango.PgMatrix; 36 private import pango.c.functions; 37 public import pango.c.types; 38 39 40 /** 41 * `PangoRenderer` is a base class for objects that can render text 42 * provided as `PangoGlyphString` or `PangoLayout`. 43 * 44 * By subclassing `PangoRenderer` and overriding operations such as 45 * @draw_glyphs and @draw_rectangle, renderers for particular font 46 * backends and destinations can be created. 47 * 48 * Since: 1.8 49 */ 50 public class PgRenderer : ObjectG 51 { 52 /** the main Gtk struct */ 53 protected PangoRenderer* pangoRenderer; 54 55 /** Get the main Gtk struct */ 56 public PangoRenderer* getPgRendererStruct(bool transferOwnership = false) 57 { 58 if (transferOwnership) 59 ownedRef = false; 60 return pangoRenderer; 61 } 62 63 /** the main Gtk struct as a void* */ 64 protected override void* getStruct() 65 { 66 return cast(void*)pangoRenderer; 67 } 68 69 /** 70 * Sets our main struct and passes it to the parent class. 71 */ 72 public this (PangoRenderer* pangoRenderer, bool ownedRef = false) 73 { 74 this.pangoRenderer = pangoRenderer; 75 super(cast(GObject*)pangoRenderer, ownedRef); 76 } 77 78 79 /** */ 80 public static GType getType() 81 { 82 return pango_renderer_get_type(); 83 } 84 85 /** 86 * Does initial setup before rendering operations on @renderer. 87 * 88 * [method@Pango.Renderer.deactivate] should be called when done drawing. 89 * Calls such as [method@Pango.Renderer.draw_layout] automatically 90 * activate the layout before drawing on it. 91 * 92 * Calls to [method@Pango.Renderer.activate] and 93 * [method@Pango.Renderer.deactivate] can be nested and the 94 * renderer will only be initialized and deinitialized once. 95 * 96 * Since: 1.8 97 */ 98 public void activate() 99 { 100 pango_renderer_activate(pangoRenderer); 101 } 102 103 /** 104 * Cleans up after rendering operations on @renderer. 105 * 106 * See docs for [method@Pango.Renderer.activate]. 107 * 108 * Since: 1.8 109 */ 110 public void deactivate() 111 { 112 pango_renderer_deactivate(pangoRenderer); 113 } 114 115 /** 116 * Draw a squiggly line that approximately covers the given rectangle 117 * in the style of an underline used to indicate a spelling error. 118 * 119 * The width of the underline is rounded to an integer number 120 * of up/down segments and the resulting rectangle is centered 121 * in the original rectangle. 122 * 123 * This should be called while @renderer is already active. 124 * Use [method@Pango.Renderer.activate] to activate a renderer. 125 * 126 * Params: 127 * x = X coordinate of underline, in Pango units in user coordinate system 128 * y = Y coordinate of underline, in Pango units in user coordinate system 129 * width = width of underline, in Pango units in user coordinate system 130 * height = height of underline, in Pango units in user coordinate system 131 * 132 * Since: 1.8 133 */ 134 public void drawErrorUnderline(int x, int y, int width, int height) 135 { 136 pango_renderer_draw_error_underline(pangoRenderer, x, y, width, height); 137 } 138 139 /** 140 * Draws a single glyph with coordinates in device space. 141 * 142 * Params: 143 * font = a `PangoFont` 144 * glyph = the glyph index of a single glyph 145 * x = X coordinate of left edge of baseline of glyph 146 * y = Y coordinate of left edge of baseline of glyph 147 * 148 * Since: 1.8 149 */ 150 public void drawGlyph(PgFont font, PangoGlyph glyph, double x, double y) 151 { 152 pango_renderer_draw_glyph(pangoRenderer, (font is null) ? null : font.getPgFontStruct(), glyph, x, y); 153 } 154 155 /** 156 * Draws the glyphs in @glyph_item with the specified `PangoRenderer`, 157 * embedding the text associated with the glyphs in the output if the 158 * output format supports it. 159 * 160 * This is useful for rendering text in PDF. 161 * 162 * Note that this method does not handle attributes in @glyph_item. 163 * If you want colors, shapes and lines handled automatically according 164 * to those attributes, you need to use pango_renderer_draw_layout_line() 165 * or pango_renderer_draw_layout(). 166 * 167 * Note that @text is the start of the text for layout, which is then 168 * indexed by `glyph_item->item->offset`. 169 * 170 * If @text is %NULL, this simply calls [method@Pango.Renderer.draw_glyphs]. 171 * 172 * The default implementation of this method simply falls back to 173 * [method@Pango.Renderer.draw_glyphs]. 174 * 175 * Params: 176 * text = the UTF-8 text that @glyph_item refers to 177 * glyphItem = a `PangoGlyphItem` 178 * x = X position of left edge of baseline, in user space coordinates 179 * in Pango units 180 * y = Y position of left edge of baseline, in user space coordinates 181 * in Pango units 182 * 183 * Since: 1.22 184 */ 185 public void drawGlyphItem(string text, PgGlyphItem glyphItem, int x, int y) 186 { 187 pango_renderer_draw_glyph_item(pangoRenderer, Str.toStringz(text), (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct(), x, y); 188 } 189 190 /** 191 * Draws the glyphs in @glyphs with the specified `PangoRenderer`. 192 * 193 * Params: 194 * font = a `PangoFont` 195 * glyphs = a `PangoGlyphString` 196 * x = X position of left edge of baseline, in user space coordinates 197 * in Pango units. 198 * y = Y position of left edge of baseline, in user space coordinates 199 * in Pango units. 200 * 201 * Since: 1.8 202 */ 203 public void drawGlyphs(PgFont font, PgGlyphString glyphs, int x, int y) 204 { 205 pango_renderer_draw_glyphs(pangoRenderer, (font is null) ? null : font.getPgFontStruct(), (glyphs is null) ? null : glyphs.getPgGlyphStringStruct(), x, y); 206 } 207 208 /** 209 * Draws @layout with the specified `PangoRenderer`. 210 * 211 * This is equivalent to drawing the lines of the layout, at their 212 * respective positions relative to @x, @y. 213 * 214 * Params: 215 * layout = a `PangoLayout` 216 * x = X position of left edge of baseline, in user space coordinates 217 * in Pango units. 218 * y = Y position of left edge of baseline, in user space coordinates 219 * in Pango units. 220 * 221 * Since: 1.8 222 */ 223 public void drawLayout(PgLayout layout, int x, int y) 224 { 225 pango_renderer_draw_layout(pangoRenderer, (layout is null) ? null : layout.getPgLayoutStruct(), x, y); 226 } 227 228 /** 229 * Draws @line with the specified `PangoRenderer`. 230 * 231 * This draws the glyph items that make up the line, as well as 232 * shapes, backgrounds and lines that are specified by the attributes 233 * of those items. 234 * 235 * Params: 236 * line = a `PangoLayoutLine` 237 * x = X position of left edge of baseline, in user space coordinates 238 * in Pango units. 239 * y = Y position of left edge of baseline, in user space coordinates 240 * in Pango units. 241 * 242 * Since: 1.8 243 */ 244 public void drawLayoutLine(PgLayoutLine line, int x, int y) 245 { 246 pango_renderer_draw_layout_line(pangoRenderer, (line is null) ? null : line.getPgLayoutLineStruct(), x, y); 247 } 248 249 /** 250 * Draws an axis-aligned rectangle in user space coordinates with the 251 * specified `PangoRenderer`. 252 * 253 * This should be called while @renderer is already active. 254 * Use [method@Pango.Renderer.activate] to activate a renderer. 255 * 256 * Params: 257 * part = type of object this rectangle is part of 258 * x = X position at which to draw rectangle, in user space coordinates 259 * in Pango units 260 * y = Y position at which to draw rectangle, in user space coordinates 261 * in Pango units 262 * width = width of rectangle in Pango units 263 * height = height of rectangle in Pango units 264 * 265 * Since: 1.8 266 */ 267 public void drawRectangle(PangoRenderPart part, int x, int y, int width, int height) 268 { 269 pango_renderer_draw_rectangle(pangoRenderer, part, x, y, width, height); 270 } 271 272 /** 273 * Draws a trapezoid with the parallel sides aligned with the X axis 274 * using the given `PangoRenderer`; coordinates are in device space. 275 * 276 * Params: 277 * part = type of object this trapezoid is part of 278 * y1 = Y coordinate of top of trapezoid 279 * x11 = X coordinate of left end of top of trapezoid 280 * x21 = X coordinate of right end of top of trapezoid 281 * y2 = Y coordinate of bottom of trapezoid 282 * x12 = X coordinate of left end of bottom of trapezoid 283 * x22 = X coordinate of right end of bottom of trapezoid 284 * 285 * Since: 1.8 286 */ 287 public void drawTrapezoid(PangoRenderPart part, double y1, double x11, double x21, double y2, double x12, double x22) 288 { 289 pango_renderer_draw_trapezoid(pangoRenderer, part, y1, x11, x21, y2, x12, x22); 290 } 291 292 /** 293 * Gets the current alpha for the specified part. 294 * 295 * Params: 296 * part = the part to get the alpha for 297 * 298 * Returns: the alpha for the specified part, 299 * or 0 if it hasn't been set and should be 300 * inherited from the environment. 301 * 302 * Since: 1.38 303 */ 304 public ushort getAlpha(PangoRenderPart part) 305 { 306 return pango_renderer_get_alpha(pangoRenderer, part); 307 } 308 309 /** 310 * Gets the current rendering color for the specified part. 311 * 312 * Params: 313 * part = the part to get the color for 314 * 315 * Returns: the color for the 316 * specified part, or %NULL if it hasn't been set and should be 317 * inherited from the environment. 318 * 319 * Since: 1.8 320 */ 321 public PgColor getColor(PangoRenderPart part) 322 { 323 auto __p = pango_renderer_get_color(pangoRenderer, part); 324 325 if(__p is null) 326 { 327 return null; 328 } 329 330 return ObjectG.getDObject!(PgColor)(cast(PangoColor*) __p); 331 } 332 333 /** 334 * Gets the layout currently being rendered using @renderer. 335 * 336 * Calling this function only makes sense from inside a subclass's 337 * methods, like in its draw_shape vfunc, for example. 338 * 339 * The returned layout should not be modified while still being 340 * rendered. 341 * 342 * Returns: the layout, or %NULL if 343 * no layout is being rendered using @renderer at this time. 344 * 345 * Since: 1.20 346 */ 347 public PgLayout getLayout() 348 { 349 auto __p = pango_renderer_get_layout(pangoRenderer); 350 351 if(__p is null) 352 { 353 return null; 354 } 355 356 return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) __p); 357 } 358 359 /** 360 * Gets the layout line currently being rendered using @renderer. 361 * 362 * Calling this function only makes sense from inside a subclass's 363 * methods, like in its draw_shape vfunc, for example. 364 * 365 * The returned layout line should not be modified while still being 366 * rendered. 367 * 368 * Returns: the layout line, or %NULL 369 * if no layout line is being rendered using @renderer at this time. 370 * 371 * Since: 1.20 372 */ 373 public PgLayoutLine getLayoutLine() 374 { 375 auto __p = pango_renderer_get_layout_line(pangoRenderer); 376 377 if(__p is null) 378 { 379 return null; 380 } 381 382 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) __p); 383 } 384 385 /** 386 * Gets the transformation matrix that will be applied when 387 * rendering. 388 * 389 * See [method@Pango.Renderer.set_matrix]. 390 * 391 * Returns: the matrix, or %NULL if no matrix has 392 * been set (which is the same as the identity matrix). The returned 393 * matrix is owned by Pango and must not be modified or freed. 394 * 395 * Since: 1.8 396 */ 397 public PgMatrix getMatrix() 398 { 399 auto __p = pango_renderer_get_matrix(pangoRenderer); 400 401 if(__p is null) 402 { 403 return null; 404 } 405 406 return ObjectG.getDObject!(PgMatrix)(cast(PangoMatrix*) __p); 407 } 408 409 /** 410 * Informs Pango that the way that the rendering is done 411 * for @part has changed. 412 * 413 * This should be called if the rendering changes in a way that would 414 * prevent multiple pieces being joined together into one drawing call. 415 * For instance, if a subclass of `PangoRenderer` was to add a stipple 416 * option for drawing underlines, it needs to call 417 * 418 * ``` 419 * pango_renderer_part_changed (render, PANGO_RENDER_PART_UNDERLINE); 420 * ``` 421 * 422 * When the stipple changes or underlines with different stipples 423 * might be joined together. Pango automatically calls this for 424 * changes to colors. (See [method@Pango.Renderer.set_color]) 425 * 426 * Params: 427 * part = the part for which rendering has changed. 428 * 429 * Since: 1.8 430 */ 431 public void partChanged(PangoRenderPart part) 432 { 433 pango_renderer_part_changed(pangoRenderer, part); 434 } 435 436 /** 437 * Sets the alpha for part of the rendering. 438 * 439 * Note that the alpha may only be used if a color is 440 * specified for @part as well. 441 * 442 * Params: 443 * part = the part to set the alpha for 444 * alpha = an alpha value between 1 and 65536, or 0 to unset the alpha 445 * 446 * Since: 1.38 447 */ 448 public void setAlpha(PangoRenderPart part, ushort alpha) 449 { 450 pango_renderer_set_alpha(pangoRenderer, part, alpha); 451 } 452 453 /** 454 * Sets the color for part of the rendering. 455 * 456 * Also see [method@Pango.Renderer.set_alpha]. 457 * 458 * Params: 459 * part = the part to change the color of 460 * color = the new color or %NULL to unset the current color 461 * 462 * Since: 1.8 463 */ 464 public void setColor(PangoRenderPart part, PgColor color) 465 { 466 pango_renderer_set_color(pangoRenderer, part, (color is null) ? null : color.getPgColorStruct()); 467 } 468 469 /** 470 * Sets the transformation matrix that will be applied when rendering. 471 * 472 * Params: 473 * matrix = a `PangoMatrix`, or %NULL to unset any existing matrix 474 * (No matrix set is the same as setting the identity matrix.) 475 * 476 * Since: 1.8 477 */ 478 public void setMatrix(PgMatrix matrix) 479 { 480 pango_renderer_set_matrix(pangoRenderer, (matrix is null) ? null : matrix.getPgMatrixStruct()); 481 } 482 }